-
Notifications
You must be signed in to change notification settings - Fork 85
[capital] Code generation: update services and models #1613
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Summary of ChangesHello @AdyenAutomationBot, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request delivers an automated update to the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This PR adds a new capital service, apparently auto-generated from an OpenAPI specification. The changes are extensive, adding many new API clients and model types. My review focuses on several areas for improvement:
- Robustness: The query parameter handling in some API methods is not robust and could lead to runtime errors.
- Consistency and Maintainability: There are inconsistencies in the generated
objectSerializer.tsand some model files contain commented-out code or empty namespaces that should be cleaned up. - Performance: The main
CapitalAPIclass creates new API instances on every access, which is inefficient.
I've provided specific comments and suggestions to address these points. Since the code is auto-generated, these changes might need to be applied to the generator templates.
| const hasDefinedQueryParams = accountHolderId; | ||
| if(hasDefinedQueryParams) { | ||
| if(!requestOptions) requestOptions = {}; | ||
| if(!requestOptions.params) requestOptions.params = {}; | ||
| if(accountHolderId) requestOptions.params["accountHolderId"] = accountHolderId; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for handling query parameters is not robust and could lead to runtime errors. It assumes requestOptions.params is an object that can be assigned properties to, but its type QueryString also allows for string, string[][], or URLSearchParams. If a caller provides requestOptions.params as one of these other types, this code would fail. Additionally, the logic is verbose and contains redundant checks (if(hasDefinedQueryParams) followed by if(accountHolderId)). A more robust and concise implementation is recommended.
| const hasDefinedQueryParams = counterpartyAccountHolderId; | ||
| if(hasDefinedQueryParams) { | ||
| if(!requestOptions) requestOptions = {}; | ||
| if(!requestOptions.params) requestOptions.params = {}; | ||
| if(counterpartyAccountHolderId) requestOptions.params["counterpartyAccountHolderId"] = counterpartyAccountHolderId; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for handling query parameters is not robust and could lead to runtime errors. It assumes requestOptions.params is an object that can be assigned properties to, but its type QueryString also allows for string, string[][], or URLSearchParams. If a caller provides requestOptions.params as one of these other types, this code would fail. Additionally, the logic is verbose and contains redundant checks (if(hasDefinedQueryParams) followed by if(counterpartyAccountHolderId)). A more robust and concise implementation is recommended.
| export default class CapitalAPI extends Service { | ||
|
|
||
| public constructor(client: Client) { | ||
| super(client); | ||
| } | ||
|
|
||
| public get GrantAccountsApi() { | ||
| return new GrantAccountsApi(this.client); | ||
| } | ||
|
|
||
| public get GrantOffersApi() { | ||
| return new GrantOffersApi(this.client); | ||
| } | ||
|
|
||
| public get GrantsApi() { | ||
| return new GrantsApi(this.client); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API getters create a new instance of the respective API class every time they are accessed. This is inefficient, especially if an API is used multiple times. It's better to use lazy initialization to create and cache the instance on first access. This improves performance by avoiding repeated object creation.
export default class CapitalAPI extends Service {
private _grantAccountsApi?: GrantAccountsApi;
private _grantOffersApi?: GrantOffersApi;
private _grantsApi?: GrantsApi;
public constructor(client: Client) {
super(client);
}
public get GrantAccountsApi(): GrantAccountsApi {
return this._grantAccountsApi ?? (this._grantAccountsApi = new GrantAccountsApi(this.client));
}
public get GrantOffersApi(): GrantOffersApi {
return this._grantOffersApi ?? (this._grantOffersApi = new GrantOffersApi(this.client));
}
public get GrantsApi(): GrantsApi {
return this._grantsApi ?? (this._grantsApi = new GrantsApi(this.client));
}
}| public constructor() { | ||
| super(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| export namespace AdditionalBankIdentification { | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public constructor() { | ||
| super(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public constructor() { | ||
| super(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public constructor() { | ||
| super(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public constructor() { | ||
| super(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| export namespace USLocalAccountIdentification { | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR contains the automated changes for the
capitalservice.The commit history of this PR reflects the
adyen-openapicommits that have been applied.